<?php
/**
 * Pertyler
 * Main Script
 *
 * @author	Emre Hasegeli <hasegeli@gmail.com>
 * @license	GNU General Public License v3
 */

namespace Pertyler;

session_start();

require 'Classes/Client.php';

require 'Classes/Date.php';

require 'Classes/Email.php';

require 'Classes/File.php';

require 'Classes/Image.php';

require 'Classes/Page.php';

require 'Classes/Link.php';

require 'Classes/Postgre.php';

require 'Classes/Tree.php';

require 'Classes/UploadedFile.php';

require 'Classes/UploadedImage.php';

require 'Classes/UploadedDocument.php';

require 'Classes/User.php';

require 'DatabaseModel/Database.php';

require 'DatabaseModel/Table.php';

require 'DatabaseModel/Role.php';

require 'DatabaseModel/Language.php';

require 'KoolControls/KoolAjax/koolajax.php';

require 'KoolControls/KoolTreeView/kooltreeview.php';

require 'config.php';

$page = new Page(Database::Postgre());

if(!(Pertyler_Role_Moderator::Select()))
{
	$tree = $page->Tree();

	if(($tree->Pressed() == 'login_okay') AND (isset($_POST['Name'])) AND ($_POST['Password']))
		if(!Pertyler_Role_Moderator::Login($_POST['Name'], $_POST['Password']))
			$tree->AddProperty('Login failed');

	if(!(Pertyler_Role_Moderator::Select()))
	{
		$tree->AddButton('login_okay');

		$tree->Add(new TreeLeaf('Name', '<input type="text" name="Name" maxlength="60">'));

		$tree->Add(new TreeLeaf('Password', '<input type="password" name="Password" maxlength="20">'));

		echo $tree;

		exit;
	}
}